package com.second.client.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.second.client.dao.ClientIntegrationDao;
import com.second.client.pojo.entity.ClientIntegration;
import com.second.client.pojo.vo.IntegrationQueryVo;
import com.second.client.pojo.vo.PageVo;
import com.second.client.service.ClientIntegrationService;
import com.second.client.util.PageData;
import com.second.common.pojo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (ClientIntegration)表服务实现类
 *
 * @author lvyongqi
 * @since 2021-07-24 09:02:26
 */
@Service("clientIntegrationService")
public class ClientIntegrationServiceImpl extends ServiceImpl<ClientIntegrationDao, ClientIntegration> implements ClientIntegrationService {

    @Resource
    private ClientIntegrationDao clientIntegrationDao;

    /**
     * 获取所有的积分记录
     * @return 所有数据
     */
    @Override
    public R getAllIntegration(PageVo pageVo, IntegrationQueryVo integrationQueryVo) {

        // 开启分页
        Page<ClientIntegration> page = new Page<>(pageVo.getCurrentPage(), pageVo.getPageSize());

        // 将获取到的page对象和前台传递的参数传递到自己写的sql查询方法，注意：返回值类型一定要是Page<T>
        Page<ClientIntegration> clientIntegrationList =
                clientIntegrationDao.getAllIntegration(page,integrationQueryVo);

        return PageData.returnPage(page,clientIntegrationList);

    }

    /**
     * 增加积分记录
     * @param clientIntegration 积分记录实体类
     * @return 结果
     */
    @Override
    public boolean addIntegrationRecord(ClientIntegration clientIntegration) {
        // 增加积分记录
        return this.save(clientIntegration);
    }

}
